package com.atom.app.mvvm.stack

import android.app.Activity
import android.app.Application
import android.os.Bundle

/**
 * All rights Reserved, Designed By www.rongdasoft.com
 *
 * @version V1.0
 * @Title: AppRegisterCallback
 * @Description:
 * @author: wuyongzheng
 * @date: 2022/1/13
 * @Copyright: 2022/1/13 www.rongdasoft.com Inc. All rights reserved.
 */
class AppRegisterCallback : Application.ActivityLifecycleCallbacks, AppStateListener {
    val appStateManager = AppStateManager

    val appStackManager = AppStackManager

    override fun onActivityCreated(
        activity: Activity,
        savedInstanceState: Bundle?
    ) {
        appStackManager.addActivity(activity)
    }

    override fun onActivityDestroyed(activity: Activity) {
        appStackManager.removeActivity(activity)
    }

    override fun onActivityPaused(activity: Activity) {
    }

    override fun onActivityResumed(activity: Activity) {
    }

    override fun onActivitySaveInstanceState(
        activity: Activity,
        outState: Bundle
    ) {
    }

    override fun onActivityStarted(activity: Activity) {
        appStateManager.onActivityShow(activity)
    }

    override fun onActivityStopped(activity: Activity) {
        appStateManager.onActivityHide(activity)
    }

    override fun appState(isShow: Boolean) {

    }

    init {
        AppStateManager.addListener(this);
    }

}